package org;

import org.beanscreator.BeanFactory;
import org.beanscreator.GenericXmlApplicationContext;
import org.beanscreator.GenericXmlApplicationContextImpl;
import org.beanscreator.parsers.ParserTypes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class App {

    private static final Logger LOGGER = LoggerFactory.getLogger(App.class);

    private static final String BEAN_DEFS_LOCATION = "src/main/resources/";
    private static final String BEAN_DEF_1 = "definitions.xml";
    private static final int DEFS_NUMBER = 6;

    private App() {
    }

    public static void main(String[] args) {

        GenericXmlApplicationContext context = new GenericXmlApplicationContextImpl();

        context.setValidating(false);
        context.setParserType(ParserTypes.DOM);
        context.load(BEAN_DEFS_LOCATION + BEAN_DEF_1);

        BeanFactory factory = null;
        GreetingService greetingService = null;

        for (int i = 1; i < DEFS_NUMBER; i++) {

            factory = context.getBeanFactory();
            greetingService = (GreetingService) factory.getBean("g" + i);

            LOGGER.debug(greetingService.toString());
        }

    }
}
